package com.swa99ylum.pxp.a.a001;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.lsy.poi.Student;



public class Foo2 {
	
	
	public <T> void query(Class<T> clazz, List<T> aaa) {
			for (T t : aaa) {
				System.out.println("=========>" + t);
			}
	//			while(resultSet.next()) {
	//				T ele = clazz.newInstance();
	//				
	//				for (String columnLabel : headers) {
	//					//3.2、通过 列名，从  resultSet 中获取 列值
	//					Object columnValue = resultSet.getObject(columnLabel);
	//					//System.out.println(columnLabel + ": " + columnValue);
	//					
	//					//3.3、通过 反射，为 javaBean 对象设置属性值
	//					//ReflectionUtils.setFieldValue(ele, columnLabel, columnValue);
	//					BeanUtils.setProperty(ele, columnLabel, columnValue);
	//				}
	//				
	//				eleList.add(ele);
	//			}
	//			
			
	}
	
	public <T> void query1(Class<T> clazz, List<T> aaa) throws InstantiationException, IllegalAccessException, InvocationTargetException {
		
		for (int i = 0; i < 3; i++) {
			T ele = clazz.newInstance();
			BeanUtils.setProperty(ele, "name", "张三" + i);
			aaa.add(ele);
		}
		
	}
	
	public static void main(String[] args) throws InstantiationException, IllegalAccessException, InvocationTargetException {
		Foo2 f = new Foo2();
		
		ArrayList<Student> arrayList = new ArrayList<Student>();
		/**
		arrayList.add(new Student(1, "aa", "aa@", new Date()));
		arrayList.add(new Student(2, "bb", "bb@", new Date()));
		arrayList.add(new Student(3, "cc", "cc@", new Date()));
		
		f.query(Student.class, arrayList);
		*/
		
		f.query1(Student.class, arrayList);
		for (Student student : arrayList) {
			System.out.println(student);
		}
	}
	
	
	
	
}
